import {
  AddCommArtRes,
  ArticleInfoType,
  CommParamsType,
  commReqType,
  CommResType
} from '@/types/data'
import http from '@/utils/http'
import { MyAxiosPromise } from '.'
// 获取文章详情
export function articlesGet (id: string): MyAxiosPromise<ArticleInfoType> {
  return http({ url: `articles/${id}`, method: 'get' })
}
// 点赞文章
export function articleLikings (target: string) {
  return http({ url: 'article/likings', method: 'post', data: { target } })
}
// 取消点赞文章
export function articleLikingsDelete (target: string) {
  return http({ url: 'article/likings/' + target, method: 'delete' })
}
// 收藏文章
export function articleCollectionPost (target: string) {
  return http({ url: 'article/collections', method: 'post', data: { target } })
}
// 取消收藏文章
export function articleCollectionDelete (target: string) {
  return http({ url: `article/collections/${target}`, method: 'delete' })
}
// 关注用户
export function userFollowingsPost (target: string) {
  return http({ url: `user/followings`, method: 'post', data: { target } })
}
// 取消关注用户
export function userFollowingsDelete (target: string) {
  return http({ url: `user/followings/${target}`, method: 'delete' })
}
// 获取文章评论
export function commentsGet (
  params: CommParamsType
): MyAxiosPromise<CommResType> {
  return http({ url: `comments`, method: 'get', params })
}
// 发表评论
export function commentsPost (
  data: commReqType
): MyAxiosPromise<AddCommArtRes> {
  return http({ url: 'comments', method: 'post', data })
}
